<?php
// +---------------------------------------------------------------------+
// | OneBase    | [ WE CAN DO IT JUST THINK ]                            |
// +---------------------------------------------------------------------+
// | Licensed   | http://www.apache.org/licenses/LICENSE-2.0 )           |
// +---------------------------------------------------------------------+
// | Author     | Bigotry <3162875@qq.com>                               |
// +---------------------------------------------------------------------+
// | Repository | https://gitee.com/Bigotry/OneBase                      |
// +---------------------------------------------------------------------+

namespace app\common\model;

/**
 * 文章模型
 */
class Article extends ModelBase
{
    protected $insert = ['create_time'];

    public function getImageAttr(){
        return get_picture_url($this->cover_id,false);
    }

    public function getVideoAttr(){
        if($this->video_type==1){
            if($this->file_id){
                return get_file_url($this->file_id,false);
            }else{
              return '';
            }

        }else{
            return $this->video_url;
        }

    }
    /**
     * 连分类表
     */
    public function cate(){
        return $this->belongsTo('ArticleCategory','category_id','id');
    }
    /**
     * 连分类表
     */
    public function videocate(){
        return $this->belongsTo('VideoCate','video_cate_id','id');
    }

    /**
     * 连标签表
     */
    public function tag(){
        return $this->belongsTo('ArticleCategory','level','id');
    }
//    public function  getNameAttr($value){
//
//        $lang=isset($_REQUEST['lang'])?$_REQUEST['lang']:'';
//        return   baidu_translate($value,$lang);
//
//
//    }

    /**
     * 连用户表
     */
    public function user(){
        return $this->belongsTo('Member','member_id','id');
    }

    /**
     * 时间自动完成
     */
    public function setCreateTimeAttr()
    {

        return TIME_NOW;
    }
  
//  public function  getCateNameAttr(){
//      $lang=isset($_REQUEST['lang'])?$_REQUEST['lang']:'';
//      return   baidu_translate($this->cate['name'],$lang);
//
//
//    }

//    public function  getDescribeAttr($value){
//
//        $lang=isset($_REQUEST['lang'])?$_REQUEST['lang']:'';
//        return   baidu_translate($value,$lang);
//
//
//    }

//    public function  getContentAttr($value){
//        $lang=isset($_REQUEST['lang'])?$_REQUEST['lang']:'';
//        return   baidu_translate($value,$lang);
//
//    }
}
